﻿using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace EfCore.Web.Services
{
    public class TestHostedService
        : BackgroundService
    {
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var timer = new Timer((state) =>Callback(state),100,100,100);
            return Task.CompletedTask;
        }

        private void Callback(object state)
        {
            Console.WriteLine(state);
        }

        public override Task StartAsync(CancellationToken cancellationToken)
        {
            Console.WriteLine("Task is starting.");
            return base.StartAsync(cancellationToken);
        }
        public override Task StopAsync(CancellationToken cancellationToken)
        {
            Console.WriteLine("Task is stopping.");
            return base.StopAsync(cancellationToken);
        }
    }
}
